﻿import QtQuick
import QtQuick.Controls
import FilUI

FilControlBackground {
    id: control

    property Item inputItem

    color                                       : {
        if (inputItem && !inputItem.enabled) {
            return Qt.rgba(252/255, 252/255, 252/255, 1)
        }
        if (inputItem && inputItem.activeFocus) {
            return Qt.rgba(1, 1, 1, 1)
        }
        if (inputItem && inputItem.hovered) {
            return Qt.rgba(251/255, 251/255, 251/255, 1)
        }
        return Qt.rgba(1, 1, 1, 1)
    }
    border.width                                : 1
    gradient                                    : Gradient {
        GradientStop { position: 0.0; color: d.startColor }
        GradientStop { position: 1 - d.offsetSize / control.height; color: d.startColor }
        GradientStop { position: 1.0; color: d.endColor }
    }
    bottomMargin                                : 1
    QtObject {
        id: d
        property int offsetSize                 : 3
        property color startColor               : Qt.rgba(232/255, 232/255, 232/255, 1)
        property color endColor                 : {
            if (!control.enabled) {
                return d.startColor
            }
            return Qt.rgba(132/255, 132/255, 132/255, 1)
        }
    }
    FilClip {
        anchors.fill                            : parent
        radius                                  : [control.radius,
                                                   control.radius,
                                                   control.radius,
                                                   control.radius]
        visible                                 : inputItem && inputItem.activeFocus
        Rectangle {
            width                               : parent.width
            height                              : 2
            anchors.bottom                      : parent.bottom
            color                               : FilTheme.primaryColor
        }
    }
}
